﻿using Castle.Core.Logging;
using log4net;
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Text;

namespace Yto.Logger
{
    public class BaseLoggerFactory : AbstractLoggerFactory
    {
        private const string DefauleConfigFile = "log4net.config";

        public BaseLoggerFactory() : this(DefauleConfigFile)
        {

        }

        public BaseLoggerFactory(string fileName)
        {
            var file = GetConfigFile(fileName);
            XmlConfigurator.ConfigureAndWatch(file);
        }

        public override ILogger Create(string name)
        {
            if(name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            return new BaseLogger(LogManager.GetLogger(name), this);
        }

        public override ILogger Create(string name, LoggerLevel level)
        {
            throw new NotImplementedException();
        }
    }
}
